<template>
  <div class="box">
    <div class="boxtop">
      <van-nav-bar title="车辆检测">
        <template #left>
          <van-icon
            name="arrow-left"
            color="#fff"
            size="18"
            @click="clickLeft"
          ></van-icon>
        </template>
      </van-nav-bar>
    </div>
    <van-tabs v-model="activeName" color="#000">
      <van-tab title="性能部件" name="a">
        <div class="BoxPictrue" v-show="ControlShowleft">
          <!-- 损伤记录 -->
          <!-- <div class="bbbbb"></div>
          <van-row>
            <van-col :span="16">
              <div class="Damagerecord">损伤记录</div></van-col
            >
            <van-col :span="3">
              <div class="buttonLeft" @click="AllCheack">全选</div>
            </van-col>
            <van-col :span="3">
              <div class="buttonLeft" @click="deleteSelect">清除</div>
            </van-col>
          </van-row>
          <van-divider /> -->
          <van-cell-group inset>
            <div v-for="(item, index) in propertyData" :key="index">
              <van-cell class="fontStyle" :border="false">{{
                item.partName
              }}</van-cell>
              <van-cell title="损伤描述" is-link @click="clickPart(item)" />
            </div>
          </van-cell-group>
          <div class="buttonBack" @click="ClickShowRight">
            <van-icon name="arrow" size="20" color="#6b6b6b" />
            <!-- 按钮 -->
          </div>
        </div>
      </van-tab>

      <van-tab title="动态部件" name="b">
        <div class="BoxPictrue" v-show="ControlShowleft">
          <van-cell-group inset>
            <div v-for="(item, index) in activetyData" :key="index">
              <van-cell class="fontStyle" :border="false">{{
                item.partName
              }}</van-cell>
              <van-cell title="损伤描述" is-link @click="clickActivity(item)" />
            </div>
          </van-cell-group>
        </div>
      </van-tab>
      <van-tab title="仪器检测" name="c">
        <div class="BoxPictrue" v-show="ControlShowleft">
          <van-cell-group inset>
            <div v-for="(item, index) in machineData" :key="index">
              <van-cell class="fontStyle" :border="false">{{
                item.partName
              }}</van-cell>
              <van-cell title="损伤描述" is-link @click="clickMachine(item)" />
            </div>
          </van-cell-group>
        </div>
      </van-tab>
    </van-tabs>

    <!-- 隐藏的页面 -->
    <div class="saftTool" v-show="ControlShowright">
      <!-- 损伤记录 -->
      <div class="bbbbb"></div>
      <van-row>
        <van-col :span="16"> <div class="Damagerecord">损伤记录</div></van-col>
        <van-col :span="3">
          <div class="buttonLeft" @click="AllCheack">全选</div>
        </van-col>
        <van-col :span="3">
          <div class="buttonLeft" @click="deleteSelect">清除</div>
        </van-col>
      </van-row>
      <van-divider />
      <div>
        <!-- <van-checkbox-group> -->
        <van-row class="numberStyle">
          <van-col :span="6">
            <!-- <van-checkbox name="a" icon-size="18px"> -->
            <span class="number">序号</span>
          </van-col>
          <van-col :span="10">
            <span>部位</span>
          </van-col>
          <van-col :span="6">操作</van-col>
        </van-row>
      </div>
      <!-- 单选框 -->
      <van-checkbox-group v-model="result" ref="checkboxGroup">
        <van-divider />
        <!-- 第二行 -->
        <van-row
          class="secondStyle"
          v-for="(item, index) in dataArry"
          :key="index"
          @change="clickchange"
        >
          <van-col :span="6">
            <van-checkbox :name="index" icon-size="18px">
              <span class="numberTwo">{{ index + 1 }}</span>
            </van-checkbox>
          </van-col>
          <van-col :span="10">
            <div class="partTwo">{{ item.part }}</div>
          </van-col>

          <van-col :span="3">
            <div class="buttonLeft">
              <span class="buttondelte" @click="delteCheack(index)">删除</span>
            </div>
          </van-col>
          <van-col :span="3">
            <div class="buttonLeft">
              <span class="button" @click="pakeUp(item)">{{
                flagShow ? "详情" : "收起"
              }}</span>
            </div>
          </van-col>
          <van-col class="injureDescribe"
            ><div v-show="item.showRecordImg">
              <span>损伤描述:</span
              ><span class="describedPart">{{ item.described }}</span>
            </div>
            <span></span
          ></van-col>
          <van-col>
            <div class="imgStyle" v-show="item.showRecordImg">
              <van-image
                width="100"
                height="100"
                v-for="(item, index) in item.children"
                :key="index"
                :src="item.content"
              ></van-image>
            </div>
          </van-col>
        </van-row>
        <van-divider />
        <!-- 隐藏按钮 -->
      </van-checkbox-group>
      <div class="buttonLeftaa" @click="ClickShow">
        <van-icon name="arrow-left" size="20" color="#6b6b6b" />
      </div>
    </div>

    <!-- -------- -->
    <div class="bottomButton">
      <div class="buttonLeft" @click="backForward">上一步</div>
      <div class="buttonRight" @click="nextStep">下一步</div>
    </div>
  </div>
</template>
<script>
// , QuerySavePart, DeleteSavePart
import { QueryAccessPart } from '@/api/user'
export default {
  data() {
    return {
      activeName: 'a',
      // 选中tab的name值
      selectedName: '',
      // 控制显示的隐藏
      ControlShowleft: true,
      ControlShowright: false,
      // 性能部件
      propertyType: '40',
      // 动态部件
      activetyType: '50',
      // 仪器检测
      machineType: '60',
      // 性能部件数据
      propertyData: [],
      // 动态部件数据
      activetyData: [],
      // 仪器检测数据
      machineData: [],
      // 单选框------
      result: [],
      // 自定义一个数组用来接收返回的数据
      dataArry: []
    }
  },
  created() {
    this.getAccessPart()
  },
  methods: {
    async getAccessPart() {
      // 获取性能部件
      try {
        const { data } = await QueryAccessPart(this.propertyType)
        this.propertyData = data
      } catch (err) {
        console.log('获取性能部件失败,请稍后重试')
      }
      // 获取动态部件
      try {
        const { data: data1 } = await QueryAccessPart(this.activetyType)
        this.activetyData = data1
      } catch (err) {
        console.log('获取动态部件失败,请稍后重试')
      }
      // 获取仪器检测
      try {
        const { data: data2 } = await QueryAccessPart(this.machineType)
        this.machineData = data2
      } catch (err) {
        console.log('获取仪器部件失败,请稍后重试')
      }
    },
    ClickShow() {
      this.ControlShowleft = !this.ControlShowleft
      this.ControlShowright = !this.ControlShowright
    },
    ClickShowRight() {
      this.ControlShowleft = !this.ControlShowleft
      this.ControlShowright = !this.ControlShowright
    },
    // 全选的按钮
    AllCheack() {
      this.$refs.checkboxGroup.toggleAll('true')
    },
    // 清除按钮
    deleteSelect(index) {
      console.log(this.result, 'tt')
      this.$store.commit('deleteAll', this.result)
    },
    clickLeft() {
      this.$router.back()
    },
    backForward() {
      this.$router.back()
    },
    // 性能部件
    clickPart(item) {
      this.custIntentId = this.$route.query.custIntentId
      // console.log(this.custIntentId);
      // console.log(item);
      this.$router.push({
        path: '/damage',
        query: { item: item, custIntentId: this.custIntentId, activeName: 'd' }
      })
    },
    // 动态部件
    clickActivity(item) {
      this.custIntentId = this.$route.query.custIntentId
      this.$router.push({
        path: '/damage',
        query: { item: item, custIntentId: this.custIntentId, activeName: 'e' }
      })
    },
    // 仪器检测
    clickMachine(item) {
      this.custIntentId = this.$route.query.custIntentId
      this.$router.push({
        path: '/damage',
        query: { item: item, custIntentId: this.custIntentId, activeName: 'f' }
      })
    },
    nextStep() {
      this.$router.push('/accessimg')
    }
  }
}
</script>
<style lang="less" scoped>
.box {
  background-color: #f6f6f9;
  .buttonLeftaa {
    position: fixed;
    left: 10px;
    top: 45%;
    width: 20px;
    height: 44px;
    border-radius: 0px 20px 20px 0px;
    background-color: #e5e5e5;
    line-height: 44px;
  }
  .BoxPictrue {
    height: 100%;
    background-color: #fff;
    width: 355px;
    margin: 0 auto;
    margin-top: 10px;
    .fontStyle {
      font-size: 15px;
      color: #333;
      font-weight: 500;
    }
    .secondStyle {
      font-size: 14px;
      color: #333;
    }
  }
  .bbbbb {
    height: 20px;
    background-color: #f6f6f9;
  }
  .Damagerecord {
    height: 45px;
    line-height: 45px;
    margin-left: 16px;
    font-size: 16px;
  }
  .buttonLeft {
    height: 45px;
    line-height: 45px;
    text-align: center;
    font-size: 0.373333rem;
    color: #4397d4;
    .button {
      display: inline;
      font-size: 0.373333rem;
    }
    // 删除按钮
    .buttondelte {
      display: inline;
      color: red;
      font-size: 0.373333rem;
    }
  }
  .saftTool {
    margin-left: 10px;
    margin-right: 10px;
    background-color: #fff;
    .bbbbb {
      height: 20px;
      background-color: #f6f6f9;
    }
    .Damagerecord {
      height: 45px;
      line-height: 45px;
      margin-left: 16px;
      // border-bottom: 1px solid #f5f5f5;
      font-size: 16px;
    }
    .buttonLeft {
      height: 45px;
      line-height: 45px;
      text-align: center;
      font-size: 0.373333rem;
      color: #4397d4;
      .button {
        display: inline;
        font-size: 0.373333rem;
      }
      // 删除按钮
      .buttondelte {
        display: inline;
        color: red;
        font-size: 0.373333rem;
      }
    }
    .van-checkbox-group {
      margin-left: 16px;
      margin-top: 16px;
      // 按钮 区域

      .buttonRight {
        width: 40px;
      }
    }
    .injureDescribe {
      width: 98%;
      font-size: 14px;
      color: #333;
      .describedPart {
        display: inline-block;
        padding-left: 20px;
      }
    }
    .imgStyle {
      width: 98%;
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      align-items: center;
      .van-image {
        flex: 1;
        width: 33.3%;
        height: 3.2rem;
        margin-right: 0.266667rem;
        margin-top: 10px;
      }
    }
    // 序号
    .numberStyle {
      height: 45px;
      line-height: 45px;
      font-size: 16px;
      text-align: center;
      .number {
        display: inline-block;
        height: 45px;
        line-height: 45px;
      }
    }
    .numberTwo {
      display: inline-block;
      height: 45px;
      line-height: 45px;
      font-size: 15px;
    }
    .partTwo {
      height: 45px;
      line-height: 45px;
      text-align: center;
      font-size: 14px;
      color: #333;
    }
  }
  .buttonBack {
    position: fixed;
    top: 350px;
    right: 10px;
    width: 20px;
    height: 40px;
    border-radius: 20px 0px 0px 20px;
    background-color: #e5e5e5;
    line-height: 40px;
  }
  .bottomButton {
    display: flex;
    justify-content: space-around;
    margin: 25px 0 30px 0;
    width: 100%;
    height: 38px;
    .buttonLeft {
      display: flex;
      justify-content: center;
      align-items: center;
      width: 160px;
      height: 38px;
      border-radius: 19px;
      border: 1px solid #4397d4;
      background-color: #fff;
      color: #4397d4;
      font-size: 14px;
    }
    .buttonRight {
      display: flex;
      justify-content: center;
      align-items: center;
      width: 160px;
      height: 38px;
      border-radius: 19px;
      background-color: #4397d4;
      color: #ffff;
      font-size: 14px;
    }
  }
}
</style>
